#include "widget.h"
#include "ui_widget.h"
#include "QLabel"
#include "QDebug"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
    , t(0)
{
    ui->setupUi(this);
    srand(time(0));

    QIcon icon=(":/")
    ui->pushButton_2->setIcon()
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_2_clicked()
{
    this->setWindowTitle("更新标题");
}

void Widget::on_pushButton_clicked()
{
    if(ui->pushButton_2->isEnabled())
    {
        ui->pushButton_2->setEnabled(false);
    }
    else
    {
        ui->pushButton_2->setEnabled(true);
    }

}

void Widget::on_pushButton_up_clicked()
{
    QRect tmp=ui->pushButton->geometry();
    ui->pushButton->setGeometry(tmp.x(),tmp.y()-5,tmp.width(),tmp.height());
}

void Widget::on_pushButton_right_clicked()
{
    //ui->pushButton->move(50,0);
    QRect tmp=ui->pushButton->geometry();
    ui->pushButton->setGeometry(tmp.x()+5,tmp.y(),tmp.width(),tmp.height());
}

void Widget::on_pushButton_down_clicked()
{
    //ui->pushButton->move(0,-50);
    QRect tmp=ui->pushButton->geometry();
    ui->pushButton->setGeometry(tmp.x(),tmp.y()-5,tmp.width(),tmp.height());
}

void Widget::on_pushButton_left_clicked()
{
    //ui->pushButton->move(-50,0);
    QRect tmp=ui->pushButton->geometry();
    ui->pushButton->setGeometry(tmp.x()+5,tmp.y(),tmp.width(),tmp.height());
}

void Widget::on_pushButton_not_pressed()
{
    t++;
    if(t==10)
    {
       qDebug()<<"hello";
       QLabel* lable=new QLabel(this);
       lable->setText("你已经点了10次了");
       lable->move(0,0);

       qDebug()<<"world";
    }
    int w=this->geometry().width()-ui->pushButton_not->geometry().width();
    int h=this->geometry().height()-ui->pushButton_not->geometry().height();
    int x=rand()%w;
    int y=rand()%h;
     ui->pushButton_not->setGeometry(x,y,ui->pushButton_not->geometry().width(),ui->pushButton_not->height());

}



void Widget::on_pushButton_f1_clicked()
{
    QFont f;
    f.setFamily("宋体");
    ui->label->setFont(f);
}

void Widget::on_pushButton_f2_clicked()
{
    QFont tmp=ui->label->font();
    int n=ui->label->font().pointSize()+1;
    tmp.setPointSize(n);
    ui->label->setFont(tmp);
}

void Widget::on_pushButton_f3_clicked()
{
    QFont tmp=ui->label->font();
    int n=ui->label->font().pointSize()-1;
    tmp.setPointSize(n);
    ui->label->setFont(tmp);
}
